// TypeScript file
module view{
    export class GameJeSuanPanel extends eui.Component {
            public user1:eui.Group;public user2:eui.Group;public user3:eui.Group;public user4:eui.Group;public user5:eui.Group;public user6:eui.Group;
            public winner_id1:eui.Label;public winner_id2:eui.Label;public winner_id3:eui.Label;public winner_id4:eui.Label;public winner_id5:eui.Label;public winner_id6:eui.Label;
            public winner_score1:eui.Label;public winner_score2:eui.Label;public winner_score3:eui.Label;public winner_score4:eui.Label;public winner_score5:eui.Label;public winner_score6:eui.Label;
            public winner_name1:eui.Label;public winner_name2:eui.Label;public winner_name3:eui.Label;public winner_name4:eui.Label;public winner_name5:eui.Label;public winner_name6:eui.Label;
            public hecha:eui.Button;
            public home:eui.Button;

            public constructor(){
                super();
                this.skinName=view.GameJeSuanSkin;
                this.hecha.addEventListener(egret.TouchEvent.TOUCH_TAP, this.BackMy, this);
                this.home.addEventListener(egret.TouchEvent.TOUCH_TAP, this.BackHome, this);
                window.localStorage.removeItem("score_type")
                window.localStorage.removeItem("rule_type");
                window.localStorage.removeItem("banker_mode");
                window.localStorage.removeItem("account_id");
                window.localStorage.removeItem("ticket_type");
                window.localStorage.removeItem("cards");
                window.localStorage.removeItem("room_number");
                window.localStorage.removeItem("room_id");
            }
              public setData(data:any):void{
                  RES.loadGroup("jiesuan");//加载结算的图片
                  var paixu={};
                  paixu["id"]=[]
                  paixu["name"]=[]
                  paixu["jinbi"]=[]
                  var money=[];
                  for(var k=0;k<data["jinbi"].length;k++){
                      money.push(data["jinbi"][k])
                  }
                  PuKeMenager.Puke().paixu(money);//输出从小到大的数组
                  for(var i=0;i<money.length;i++){
                       for(var k=0;k<money.length;k++){
                            if(money[i]==data["jinbi"][k]){
                                paixu["id"][i]=data["id"][k];
                                paixu["name"][i]=data["name"][k];
                                paixu["jinbi"][i]=data["jinbi"][k];
                            }
                       }
                  }
                  if(paixu["id"].length==2){
                      this.user1.visible=this.user2.visible=true;
                      this.winner_id1.text=paixu["id"][1];
                      this.winner_name1.text=paixu["name"][1];
                      this.winner_score1.text=paixu["jinbi"][1];
                      this.winner_id2.text=paixu["id"][0];
                      this.winner_name2.text=paixu["name"][0];
                      this.winner_score2.text=paixu["jinbi"][0];
                  }
                  if(paixu["id"].length==3){
                      this.user1.visible=this.user2.visible=this.user3.visible=true;
                      this.winner_id1.text=paixu["id"][2];
                      this.winner_name1.text=paixu["name"][2];
                      this.winner_score1.text=paixu["jinbi"][2];
                      this.winner_id2.text=paixu["id"][1];
                      this.winner_name2.text=paixu["name"][1];
                      this.winner_score2.text=paixu["jinbi"][1];
                      this.winner_id3.text=paixu["id"][0];
                      this.winner_name3.text=paixu["name"][0];
                      this.winner_score3.text=paixu["jinbi"][0];
                  }
                  if(paixu["id"].length==4){
                      this.user1.visible=this.user2.visible=this.user3.visible=this.user4.visible=true;
                      this.winner_id1.text=paixu["id"][3];
                      this.winner_name1.text=paixu["name"][3];
                      this.winner_score1.text=paixu["jinbi"][3];
                      this.winner_id2.text=paixu["id"][2];
                      this.winner_name2.text=paixu["name"][2];
                      this.winner_score2.text=paixu["jinbi"][2];
                      this.winner_id3.text=paixu["id"][1];
                      this.winner_name3.text=paixu["name"][1];
                      this.winner_score3.text=paixu["jinbi"][1];
                      this.winner_id4.text=paixu["id"][0];
                      this.winner_name4.text=paixu["name"][0];
                      this.winner_score4.text=paixu["jinbi"][0];
                  }
                  if(paixu["id"].length==5){
                      this.user1.visible=this.user2.visible=this.user3.visible=this.user4.visible=this.user5.visible=true;
                      this.winner_id1.text=paixu["id"][4];
                      this.winner_name1.text=paixu["name"][4];
                      this.winner_score1.text=paixu["jinbi"][4];
                      this.winner_id2.text=paixu["id"][3];
                      this.winner_name2.text=paixu["name"][3];
                      this.winner_score2.text=paixu["jinbi"][3];
                      this.winner_id3.text=paixu["id"][2];
                      this.winner_name3.text=paixu["name"][2];
                      this.winner_score3.text=paixu["jinbi"][2];
                      this.winner_id4.text=paixu["id"][1];
                      this.winner_name4.text=paixu["name"][1];
                      this.winner_score4.text=paixu["jinbi"][1];
                      this.winner_id5.text=paixu["id"][0];
                      this.winner_name5.text=paixu["name"][0];
                      this.winner_score5.text=paixu["jinbi"][0];
                  }
                  if(paixu["id"].length==6){
                      this.user1.visible=this.user2.visible=this.user3.visible=this.user4.visible=this.user5.visible=this.user6.visible=true;
                      this.winner_id1.text=paixu["id"][5];
                      this.winner_name1.text=paixu["name"][5];
                      this.winner_score1.text=paixu["jinbi"][5];
                      this.winner_id2.text=paixu["id"][4];
                      this.winner_name2.text=paixu["name"][4];
                      this.winner_score2.text=paixu["jinbi"][4];
                      this.winner_id3.text=paixu["id"][3];
                      this.winner_name3.text=paixu["name"][3];
                      this.winner_score3.text=paixu["jinbi"][3];
                      this.winner_id4.text=paixu["id"][2];
                      this.winner_name4.text=paixu["name"][2];
                      this.winner_score4.text=paixu["jinbi"][2];
                      this.winner_id5.text=paixu["id"][1];
                      this.winner_name5.text=paixu["name"][1];
                      this.winner_score5.text=paixu["jinbi"][1];
                      this.winner_id6.text=paixu["id"][0];
                      this.winner_name6.text=paixu["name"][0];
                      this.winner_score6.text=paixu["jinbi"][0];
                  }
              }
            private BackHome(e: egret.TouchEvent): void {//返回首页
                if (window["go"]) {
                    window["go"]("http://www.kw08.cn/game.php/index/index69.html")
                }
            }
            private BackMy(e: egret.TouchEvent): void {//查看积分
                if (window["go"]) {
                    window["go"]("http://www.kw08.cn/game.php/MyHome/homepage.html")
                }
            }
    }
}